import commonlang3.CommonLang3ThreadPoolFactory;
import guava.GuavaThreadPoolFactory;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutorService;

@Slf4j
public class ThreadPoolDemo {

    public static void main(String[] args) {
        ExecutorService guavaThreadPool = GuavaThreadPoolFactory.getThreadPool();
        ExecutorService commonLang3ThreadPool = CommonLang3ThreadPoolFactory.getThreadPool();
        executeTasks(guavaThreadPool);
        executeTasks(commonLang3ThreadPool);
        guavaThreadPool.shutdown();
        commonLang3ThreadPool.shutdown();
    }

    private static void executeTasks(ExecutorService threadPool) {
        for (int i = 0; i < 10; i++) {
            threadPool.execute(() -> {
                log.info("{} is working", Thread.currentThread().getName());
            });
        }
    }
}
